<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>来趣客服系统查询</title>
<link href="css/login_css.css" rel="stylesheet" type="text/css" />
<script src='../js/jquery.min.js'></script>
</head>
<body>
<div class="login">
	<div class="login_content">
    	<div class="login_form">
        	<div class="login_title"><img src="images/login-form_r2_c3.jpg" />
            </div>
            <div class="userid_bg">
            	<input class="UserId" name='username' type="text"/>
            </div>
            <div class="userpwd_bg">
            	<input class="Userpwd" name='password' type="password"/>
            </div>
            <a class="login_button" id="login_button" href="javascript:void(0);">
            </a>
            <div class="login_fail_tip"></div>
        </div>
    </div>

</div>
<script type="text/javascript" charset="utf-8">
    $("#login_button").click(function() {
        var username = $("[name='username']").val();
        var password = $("[name='password']").val();
        if (username === "" || password === "")
        {
            //$(".login_fail_tip").text("亲,报出您的大名,说出通关密语!");
            show_login_fail_tip();
            return false;
        }
        var login_url = 'doLogin.php';
        $.ajax({
            url: login_url,
            type: 'POST',
            data: {'username':username,'password':password},
            dataType: 'json',
            success: function(data){
                if (data && data.success === "true")
                {
                    // 财务登陆自己的系统
                    if (data.data.role === "finance")
                    {
                        window.location = "../finance/index.php";
                    } else {
                        window.location = "index.php";
                    }
                } else {
                    show_login_fail_tip();
                }
            }
       });
    });
    function show_login_fail_tip()
    {
        $(".login_fail_tip").html('<img src="images/login-form_r10_c2.jpg" />');
    }
    // bind events
    $("[name='password'],[name='username']").keydown(function(event) {
        // enter key is pressed
        if (event.keyCode === 13)
        {
            event.preventDefault();
            $("#login_button").trigger('click');
        }
    });
</script>
</body>
</html>
